#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-11-16 9:36 上午
# @Author  : yangdy
# @File    : 2020-11-16.406.根据身高重建队列
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
        people.sort(key=lambda x: (-x[0], x[1]))
        n = len(people)
        ans = list()
        for person in people:
            ans[person[1]:person[1]] = [person]
        return ans

